package com.wenhuang.chatgptopen.controller;

import com.wenhuang.chatgptopen.mapper.FansMapper;
import com.wenhuang.chatgptopen.pojo.Fans;
import com.wenhuang.chatgptopen.pojo.User;
import com.wenhuang.chatgptopen.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/*
 *@Time：2023/6/2
 *@Author：Jelly
 */
@Controller
public class RoomController {

    @Autowired
    private UserService userService;

    @Autowired
    private FansMapper fansMapper;

    //好友列表
    @GetMapping("/getFans")
    @ResponseBody
    public List<User> getFans(Fans fans


    ) {
        return fansMapper.getFans(fans);
    }

    //搜索功能（1）
    @PostMapping("/3")
    @ResponseBody
    public void search(@RequestParam("username") String username) {

        String s = "";
        s = userService.selectUsername(username);
        if(s!=null) {
            //查询成功
            System.out.println(s);
//            return s;
        }else {
            //查询失败
            s = "查无此用户";
            System.out.println(s);
//            return s;
        }

    }
}
